package com.laf.manage.controller.admin;

import java.util.List;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;

import com.laf.common.utils.poi.ExcelUtil;
import com.laf.manage.domain.po.PushMsg;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.laf.common.annotation.Log;
import com.laf.common.core.controller.BaseController;
import com.laf.common.core.domain.AjaxResult;
import com.laf.common.enums.BusinessType;

import com.laf.manage.service.IPushMsgService;

import com.laf.common.core.page.TableDataInfo;

/**
 * 消息推送记录Controller
 *
 * @author zian
 * @date 2024-10-30
 */
@Api(tags="消息推送记录管理")
@RestController("adminPushMsgController")
@RequestMapping("/admin/pushMsg")
public class PushMsgController extends BaseController
{
    @Autowired
    private IPushMsgService pushMsgService;

    /**
     * 查询消息推送记录列表
     */
    @ApiOperation("查询消息推送记录列表")
    @PreAuthorize("@ss.hasPermi('manage:pushMsg:list')")
    @GetMapping("/list")
    public TableDataInfo list(PushMsg pushMsg)
    {
        startPage();
        List<PushMsg> list = pushMsgService.selectPushMsgList(pushMsg);
        return getDataTable(list);
    }

    /**
     * 导出消息推送记录列表
     */
    @ApiOperation("导出消息推送记录列表")
    @PreAuthorize("@ss.hasPermi('manage:pushMsg:export')")
    @Log(title = "消息推送记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PushMsg pushMsg)
    {
        List<PushMsg> list = pushMsgService.selectPushMsgList(pushMsg);
        ExcelUtil<PushMsg> util = new ExcelUtil<PushMsg>(PushMsg.class);
        util.exportExcel(response, list, "消息推送记录数据");
    }

    /**
     * 获取消息推送记录详细信息
     */
    @ApiOperation("获取消息推送记录详细信息")
    @PreAuthorize("@ss.hasPermi('manage:pushMsg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pushMsgService.getById(id));
    }

    /**
     * 新增消息推送记录
     */
    @ApiOperation("新增消息推送记录")
    @PreAuthorize("@ss.hasPermi('manage:pushMsg:add')")
    @Log(title = "消息推送记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PushMsg pushMsg)
    {
        return toAjax(pushMsgService.save(pushMsg));
    }

    /**
     * 修改消息推送记录
     */
    @ApiOperation("修改消息推送记录")
    @PreAuthorize("@ss.hasPermi('manage:pushMsg:edit')")
    @Log(title = "消息推送记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PushMsg pushMsg)
    {
        return toAjax(pushMsgService.updateById(pushMsg));
    }

    /**
     * 删除消息推送记录
     */
    @ApiOperation("删除消息推送记录")
    @PreAuthorize("@ss.hasPermi('manage:pushMsg:remove')")
    @Log(title = "消息推送记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pushMsgService.removeByIds(Arrays.asList(ids)));
    }
}
